home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 July / macformat-026.iso / mac / Shareware City / Developers / video-toolbox-95-01-14-c / VideoToolbox / VideoToolboxSources / VideoToolbox.h < prev    next >
Encoding:
Text File  |  1995-01-07  |  40.5 KB  |  1,154 lines  |  [TEXT/KAHL]

  1. /*
  2. VideoToolbox.h
  3. This file contains the necessary prototypes for use of all the VideoToolbox
  4. files except Luminance.c, which has its own header file, Luminance.h, and
  5. GDInfo.c and GDTestClut.c, which use GDInfo.h.
  6.  
  7. Precompilation of this header, producing either VideoToolbox.pre or
  8. VideoToolboxMATLAB.pre, will reduce your compilation time tenfold. See
  9. VideoToolbox.c or VideoToolboxMATLAB.c for instructions.
  10.  
  11. Header files whose precompilation depends on the mc68881 or mc68020 THINK C
  12. compiler options (i.e. math.h and mc68881.h) were omitted from VideoToolbox.h so
  13. that the resulting precompiled header file can be used in projects regardless of
  14. those options. (You’ll want them enabled for speed in your lab, but you’ll
  15. usually want them disabled for portability on the road, e.g. the PowerBook 160
  16. has no floating point unit.) If you change other options that affect the
  17. pre-compilation of the headers (e.g. size of double or size of int) you should
  18. rebuild the precompiled header file, to reflect the new settings.
  19.  
  20. The precompilation _does_ depend on the sizeof(double) and sizeof(int)
  21. because most functions use or return such values and the external interface must
  22. allow the appropriate amount of space. THINK C supports a 12-byte "universal"
  23. format double that works well both with the 68881 fpu (which uses the top two
  24. bytes and the bottom 8 bytes) and with SANE (which uses the bottom 10 bytes).
  25. Thus in THINK C it is easy to mix modules compiled with (e.g. your code) and
  26. without (e.g. the ANSI library) the 68881 option. Unfortunately that excellent
  27. feature is unique to THINK C. In MPW and CodeWarrior C you must use 10-byte
  28. doubles when you use SANE (i.e. don't use the 68881 fpu), so when you use these
  29. compilers you'll need separate pre-compiled headers, with and without the 68881
  30. option, if you want to compile for each environment: to use the 68881 fpu, or
  31. run on machines that lack it.
  32.  
  33. Metrowerks CodeWarrior project names end in "µ", and indicate which cpu they
  34. support by "68k" or "ppc". THINK C projects support only the 68k and have names
  35. ending in "π".
  36.  
  37. My naming convention for pre-compiled headers indicates the size of int, "2i" or
  38. "4i", and, if the 68881 is required, "881". Metrowerks pre-compiled headers
  39. indicate which cpu they support by "68k" or "ppc"; THINK C supports only the
  40. 68k. The THINK C pre-compiled header that I use is "VideoToolbox.pre", which
  41. uses 2-byte ints and "universal" 12-byte doubles that work with or without the
  42. 68881. (The THINK C ANSI library requires 2-byte ints.) The Metrowerks
  43. CodeWarrior C pre-compiled headers that I use are called,
  44. "VideoToolbox.68k.4i.pre", "VideoToolbox.68k.4i.881.pre", and
  45. "VideoToolbox.ppc.pre".
  46.  
  47. MAC_C:
  48.  
  49. The Apple Macintosh header files use some extensions to C that are not part of
  50. Standard C, e.g. "pascal", "short double", enums larger than ints, and function
  51. prototypes that specify absolute addresses. These keywords and constructions
  52. cannot be compiled in Standard C. The macro MAC_C is defined as true, below,
  53. only on Macintosh C compilers that incorporate these extensions, and is false
  54. otherwise. The MAC_C symbol is used to prevent inclusion of all the
  55. Macintosh-dependent header files and prototypes when the compiler doesn't
  56. support them. However, lacking any general test for these extensions, a test
  57. must be added, below, for each new compiler. At present we test for Symantec's
  58. THINK C, Apple's MPW C, and Metrowerks CodeWarrior C.
  59.  
  60. MATLAB:
  61.  
  62. The VideoToolbox sources can be linked to create a stand-alone C application, or
  63. a MATLAB external code resource (a "MEX" file), to be invoked by typing the
  64. function name from within MATLAB. In that case we call the THINK C project a
  65. "MATLAB project". A MATLAB project must #define the symbol MATLAB as true for
  66. every C file, must #include the VideoToolbox.h header at the beginning of every
  67. C file, and must #include MATLABMain.h in the main C file.
  68.  
  69. Don't #define MATLAB within your C file; use the Edit:Options:THINK C:Prefix
  70. window instead. E.g. you could type
  71.     #define MATLAB 1
  72. into the Prefix window, or, more conveniently (because it speeds up your
  73. compilations enormously), type
  74.     #include "VideoToolboxMATLAB.pre"
  75. See VideoToolboxMATLAB.c for instructions.
  76.  
  77. The MATLABMain.h header allocates space for QuickDraw globals for use by THINK C
  78. MATLAB projects. It should be #included in the main C file of each THINK C
  79. MATLAB project, i.e. in the C file that contains "main" or "user_fcn". It must
  80. be included in exactly one source file of each project, as the THINK C Linker
  81. will otherwise complain.
  82.  
  83. dgp & dhb.
  84. Copyright 1989-1994 © Denis G. Pelli
  85.  
  86. HISTORY: (omitting changes documented in C files)
  87. 2/20/93 dhb    Added various commonly used headers.  
  88.             Restructured so that only VideoToolbox.h has to be included,
  89.             whether one is creating stand-alone THINK C or code resources
  90.             to be called by MATLAB. Everything that cares is properly conditioned
  91.             by the symbol MATLAB.
  92. 7/9/93    dgp    Changed our convention for the MATLAB symbol, defining it as
  93.             1 or 0 instead of defining or leaving undefined. The advantage of
  94.             this approach is that "MATLAB" can now be used as an argument in an
  95.             ordinary if statement, which is much more readable than #if.
  96. 8/21/93    dhb    Added undefs in #if MATLAB so that memory allocation goes through THINK C 
  97.             library, not as callback. Callbacks would be OK except that the Mathworks 
  98.             forgot to give us one for realloc. This leads to mixing memory managers
  99.              on the same pointers -- bad bad bad.
  100. 9/2/93    dhb    commented out #include <TranslateLinefeeds.h> since it's
  101.             not presently compatible with MATLAB.
  102. 9/2/93    dgp    Moved the NL and NEWLINE macros from Assign.c into this file.
  103. 9/8/93    dgp    Mention VideoToolbox.c.
  104. 9/11/93    dhb,dgp    Define STDIO_INT and STDIO_DOUBLE.
  105. 9/12/93    dhb    Change STDIO_... to PRINTF_... and SCANF_...
  106.             Insert conditional for MATLAB 3.5 vs. 4.x
  107. 9/14/93    dhb    Conditional for MATLAB changed to make symbol match major version number.
  108.             Removed traces of old trying to force 4 byte ints for MATLAB.
  109. 9/14/93    dgp    Moved up inclusion of QuickDraw.h before MATLAB stuff, since cmex.h
  110.             requires it. Fixed typo, changing "#elseif" to "#elif".
  111. 9/15/93    dgp    Edited the comments above, referring to VideoToolbox.c and the new 
  112.             VideoToolboxMATLAB.c.
  113. 9/16/93    dgp    Added contents of former Assign.h.
  114.             Defined MAC_C so that the VideoToolbox.h header may be used with
  115.             Standard C.
  116. 9/16/93    dhb Removed prototype for obsolete GetDateTimeString.
  117. 10/2/93    dgp    Added #include <Errors.h>.
  118. 12/1/93 dgp Now always write "MATLAB" in all caps, since that's the trademarked name.
  119. 12/16/93 dhb Somewhere things got munged.  Conditional for MATLAB version appeared
  120.            before inclusion of cmex, which won't work.  I fixed the order.
  121. 12/16/93 dhb Commented out inclusion of TranslateLineFeeds.h down below.  This
  122.            generates a link error from MATLAB.
  123. 12/29/93 dgp added #include <Packages.h>
  124. 6/12/94  dgp added definition of Apple's new BlockMoveData, for compatibility with
  125.             Apple's old pre-Universal header files.
  126. 6/12/94    dgp #include Strings.h if Universal header files are used.
  127. 7/28/94 dgp Added test for Metrowerks CodeWarrior C.
  128. 9/2/94    dgp #include MacMemory.h
  129. 9/5/94    dgp changed "int" to "short int" in definitions of PRINTF_INT and SCANF_INT for
  130.             MATLAB 4. This is based on common sense, not testing or detailed knowledge.
  131. */
  132. #pragma once            /*  suppress multiple inclusions of this file */
  133. #ifndef _VIDEOTOOLBOX_    /*  suppress multiple inclusions of this file */
  134. #define _VIDEOTOOLBOX_
  135. /*
  136. Header files that are required for successful compilation of the rest of this
  137. file are marked "required".
  138. */
  139. #if THINK_C                /* THINK C */    \
  140.     || applec            /* MPW C, presumably with Mac extensions */\
  141.     || __MWERKS__        /* Metrowerks CodeWarrior C, " */
  142.     #if THINK_C
  143.         #if __option(thinkc)
  144.             #define MAC_C 1        /* allow Macintosh C extensions: "pascal", "short double", etc. */
  145.         #else
  146.             #define MAC_C 0        /* Standard C */
  147.         #endif
  148.     #else
  149.         #define MAC_C 1            /* allow Macintosh C extensions: "pascal", "short double", etc. */
  150.     #endif
  151. #else
  152.     #define MAC_C 0                /* Standard C */
  153. #endif
  154. #ifndef SHORT_DOUBLE_OK
  155.     #define SHORT_DOUBLE_OK MAC_C    /* "short double" not allowed by Standard C */
  156. #endif
  157. #include <stdio.h>            /*  required */
  158. #include <stdlib.h>
  159. #if MAC_C
  160.     #include <Quickdraw.h>    /*  required */
  161. #endif
  162. #ifndef MATLAB
  163.     #define MATLAB 0
  164. #endif
  165. #if MATLAB
  166.     /*
  167.     This must come after stdlib.h, stdio.h, and QuickDraw.h and before everything
  168.     else. If MATLAB is true then we include the header file cmex.h.  Otherwise we
  169.     define the data types that are normally provided by that header, so that code
  170.     that uses these types may be compiled for use in applications.  It must come
  171.     before we test for version 3 or 4.  The version 3 cmex.h does not define the
  172.     symbol mex_h; version 4 does.  This is what we use to figure out which
  173.     version we are compiling for.  Sound complicated?  Sigh!
  174.     */
  175.     
  176.     #include <cmex.h>
  177.     // Test for MATLAB 4 or MATLAB 3, and set symbol appropriately.
  178.     #undef MATLAB
  179.     #ifdef mex_h
  180.         #define MATLAB 4
  181.     #else
  182.         #define MATLAB 3
  183.     #endif
  184.     #ifndef MAC_C
  185.         #error "MATLAB requires the Macintosh extensions to C."
  186.     #endif
  187.  
  188.     // Undefine the macros that override memory allocation.  MATLAB's implementation
  189.     // doesn't work if you use realloc.
  190.     #undef malloc
  191.     #undef calloc
  192.     #undef free
  193.     
  194.     // Define data types for printf, scanf.
  195.     #if (MATLAB == 4)                        /* Version 4 */
  196.         typedef short int PRINTF_INT;        /* type of arguments to printf et al. */
  197.         typedef long double PRINTF_DOUBLE;
  198.         typedef short int SCANF_INT;        /* type of arguments to scanf et al. */
  199.         typedef double SCANF_DOUBLE;
  200.     #elif (MATLAB == 3)                        /* Version 3.5 */
  201.         typedef long int PRINTF_INT;        /* type of arguments to printf et al. */
  202.         typedef double PRINTF_DOUBLE;
  203.         typedef short int SCANF_INT;        /* type of arguments to scanf et al. */
  204.         typedef long double SCANF_DOUBLE;    
  205.     #endif
  206.     #ifdef THINK_C    /* Declare our own QuickDraw globals, allocated by MATLABMain.h */
  207.         extern THINK_C_QD mex_qd;
  208.         #define qd mex_qd
  209.     #else
  210.         #define mex_qd qd
  211.     #endif
  212.     #if defined(MAIN)                        /* Some old programs #define MAIN. */
  213.         #include "MATLABMain.h"                /* New programs just #include directly. */
  214.     #endif
  215. #else
  216.     typedef long int INT;
  217.     #if SHORT_DOUBLE_OK
  218.         typedef short double DOUBLE;/* not allowed by Standard C */
  219.     #endif
  220.     typedef int PRINTF_INT;            /* type of arguments to printf et al. */
  221.     typedef double PRINTF_DOUBLE;
  222.     typedef int SCANF_INT;            /* type of arguments to scanf et al. */
  223.     typedef double SCANF_DOUBLE;
  224.     #if SHORT_DOUBLE_OK
  225.         typedef struct {
  226.             char *name;
  227.             INT type;
  228.             INT m;
  229.             INT n;
  230.             DOUBLE *pr;
  231.             DOUBLE *pi;
  232.         } Matrix;
  233.     #endif
  234. #endif
  235.  
  236. /*  Standard C headers */
  237. #include <ctype.h>
  238. #include <float.h>
  239. #include <limits.h>
  240. #include <string.h>
  241. #include <time.h>
  242.  
  243. /*  Macintosh headers */
  244. /*
  245. The inclusion, above, of Quickdraw.h will result in the inclusion of MixedMode.h
  246. only if the Universal Headers are used, since the Universal Headers and the Mixed
  247. Mode Manager are both new, providing universal support for 68k and ppc Macs.
  248. */
  249. #if defined(__MIXEDMODE__)
  250.     #if defined(GENERATINGPOWERPC) || defined(GENERATING68K)
  251.         #define UNIVERSAL_HEADERS 2    /* version 2 */
  252.     #else
  253.         #define UNIVERSAL_HEADERS 1    /* version 1 */
  254.     #endif
  255. #else
  256.     #define UNIVERSAL_HEADERS 0
  257. #endif
  258. #if MAC_C
  259.     #if THINK_C
  260.         #include <console.h>
  261.     #endif
  262.     #include <Devices.h>
  263.     #include <Errors.h>
  264.     #include <Events.h>
  265.     #include <FixMath.h>    /*  Must come before mc68881.h */
  266.     #include <Fonts.h>
  267.     #include <GestaltEqu.h>
  268.     #include <Memory.h>
  269.     #include <OSEvents.h>
  270.     #include <OSUtils.h>    /*  required */
  271.     #include <Packages.h>
  272.     #include <Palettes.h>
  273.     #if THINK_C
  274.         #include <profile.h>/* only needed if you want timing info */
  275.     #endif
  276.     #include <QDOffscreen.h>
  277.     #include <Resources.h>
  278.     #include <Retrace.h>    /*  required */
  279.     #include <Slots.h>
  280.     #include <Sound.h>
  281.     #if !defined(THINK_C) || UNIVERSAL_HEADERS
  282.         #include <Strings.h>/* c2pstr() and p2cstr() */
  283.         #define CtoPstr c2pstr
  284.         #define PtoCstr p2cstr
  285.     #else
  286.         #include <pascal.h>    /* CtoPStr() and PtoCStr() */
  287.         #ifndef c2pstr
  288.             #define c2pstr(s) CtoPstr(s)
  289.             #define p2cstr(s) PtoCstr(s)
  290.         #endif
  291.     #endif
  292.     #include <Timer.h>        /*  required */
  293.     #include <ToolUtils.h>
  294.     #include <Video.h>
  295.     #include <Windows.h>    /*  required */
  296.     // Old Memory.h header files, before Apple's Universal Headers, don't define the new
  297.     // BlockMoveData(), so we do it here, to retain compability with the old header files.
  298.     #if !UNIVERSAL_HEADERS
  299.         #pragma parameter BlockMoveData(__A0,__A1,__D0)
  300.         extern pascal void BlockMoveData(const void *srcPtr,void *destPtr,Size byteCount)=0xA22E;
  301.     #endif
  302. #endif
  303.  
  304. /*
  305. This redefines the standard C functions, malloc, etc. to instead call Apple's
  306. corresponding routines, e.g. NewPtr. The THINK C memory management routines are 
  307. poor because they are bad about freeing space, tending to fragment the free space. 
  308. */
  309. #if THINK_C
  310.     #include "MacMemory.h"
  311. #endif
  312.  
  313. /*
  314. MATLAB AND THE NEWLINE CHARACTER
  315. In most C environments the newline character is '\n' (ascii 10). In Apple's
  316. wisdom they chose to separate lines in Macintosh files with the ascii 13
  317. character, which is usually called the return character '\r'. Standard C
  318. specifies that the stdio library will use '\n' as the newline character. This
  319. potentially creates a compatibility problem between Mac C programs and C
  320. programs written for the rest of the world's computers, since one wants any text
  321. files they produce to be appropriate to the local environment. Both MPW and
  322. THINK C resolve the problem behind the scenes, but they do it in different ways.
  323. MPW redefines the association between symbolic names and character codes, making
  324. '\n' be 13 and '\r' be 10. THINK C instead modifies the stdio library so that
  325. reads and writes to a "text" (i.e. not binary) stream are translated, exchanging
  326. character codes 10 and 13. Both solutions work. However, when we use THINK C to
  327. create code resources for MATLAB we are forced to use the MPW stdio library that
  328. is built into MATLAB. Unfortunately this bypasses both compilers' fixes to the
  329. newline problem. The problem affects every single text i/o operation, e.g. every
  330. printf and scanf. Alas, there is no way to get the pre-processor to redefine /n
  331. and /r.
  332.  
  333. We have attempted two solutions: a quick fix, using macros NL and NEWLINE, and a
  334. complete clean fix, using TranslateLinefeeds.c. At present only the quick fix
  335. works.
  336.  
  337. Our quick fix is to create a macro called NL that is normally defined as the
  338. newline string "\n", but which is instead defined as "\015" (i.e. ascii 13) when
  339. MATLAB is true. Programs such as Assign.c that have replaced all instances of
  340. "\n" by NL will then work whether or not MATLAB is true. The obvious drawback is
  341. that this quick solution requires these modifications to the source files.
  342.  
  343. The clean relatively complete solution is to insert a filter,
  344. TranslateLinefeeds.c, that intercepts the calls to the stdio library and
  345. translates /r to /n and vice versa for i/o to text files. The header file
  346. TranslateLinefeeds.h redefines all the stdio calls as macros that call
  347. corresponding routines within TranslateLinefeeds.c. Note that scanf is not
  348. intercepted and that for printf (and fprintf, ...) only the format string
  349. is translated; linefeeds hiding in char or string arguments in the variable
  350. part of the argument list are not be translated.
  351. */
  352. #if MATLAB && THINK_C            /* Clean, relatively complete solution */
  353.     //#include <TranslateLinefeeds.h>
  354. #endif
  355. #if !defined(_TranslateLinefeeds_) && MATLAB && THINK_C    /* Quick fix */
  356.     #define NL "\r"
  357.     #define NEWLINE '\r'
  358. #else
  359.     #define NL "\n"        /* the standard new-line string */
  360.     #define NEWLINE '\n'
  361. #endif
  362.  
  363. /*
  364. TRUE and FALSE
  365. */
  366. #ifndef TRUE
  367.     #define FALSE    0
  368.     #define TRUE    1
  369. #endif
  370.  
  371. /*
  372. NAN & INF
  373. If you're using NAN and INF you'll be interested in the IsNan(), IsInf(), and
  374. IsFinite() definitions & prototypes below. When compiling for a PowerPC, 
  375. math.h includes the fp.h header, which defines INFINITY and NAN.
  376. */
  377. #if !defined(INF)
  378.     #define INF HUGE_VAL    /* defined in math.h */
  379. #endif
  380. #if !defined(NAN) && !defined(powerc)
  381. //    #define NAN    (0.0/0.0)    /* evaluated at runtime */
  382.     #define NAN    Nan            /* global defined in Nan.c */
  383. #endif
  384.  
  385. /*
  386. NUMERICAL CONSTANTS
  387. It's sad to say, but THINK C 5.02 loses two bits of precision converting between
  388. doubles and ascii text, in either direction. Thus you will obtain more accurate
  389. results by computing the numerical constants below at runtime rather than using
  390. these predefined constants. The ANSI Numerical C Extensions group is moving to
  391. require C compilers to preserve precision, so there is hope for the future. Of
  392. course most applications would never notice a loss of two bits precision out of
  393. the total double precision given by the 64 bits in the mantissa.
  394. */
  395. #if !defined(PI)
  396.     #define PI        3.1415926535897932385    /* computed in Mathematica */
  397. #endif
  398. #if !defined(LOGPI)
  399.     #define LOGPI    1.14472988584940017414    /* computed in Mathematica */
  400. #endif
  401. #if !defined(LOG2)
  402.     #define LOG2    0.69314718055994530942    /* computed in Mathematica */
  403. #endif
  404. #if !defined(LOG10)
  405.     #define LOG10    2.30258509299404568402    /* computed in Mathematica */
  406. #endif
  407.  
  408. #if MAC_C
  409.     /*
  410.     CLUTSIZE
  411.     Inline code that returns the same answer as GDClutSize(device).
  412.     */
  413.     #define GDCLUTSIZE(device) (gdClutSizeTable[(**(**(device)).gdPMap).pixelSize])
  414.     
  415.     /*  Commented out, because its answer is misleading when in 16-bit or 32-bit mode. */
  416.     /* #define GDCOLORS(device) ((**(**(**device).gdPMap).pmTable).ctSize+1) */
  417. #endif
  418.  
  419. /*
  420. FIXED POINT ARITHMETIC
  421. Apple defines a handy data type called Fixed that is stored in a long, but is
  422. assumed to have a decimal point in the middle. Many operations, e.g. adding two
  423. Fixed numbers or multiplying or dividing a Fixed by an integer, can be performed
  424. directly. To multiply or divide two Fixed numbers use Apple's FixMul() and
  425. FixDiv(). FixRatio(n,m) returns the Fixed ratio of two integers. Macintosh C
  426. compilers define double in various ways, depending on whether a floating point
  427. unit is to be used. The Apple-provided routines for doing type conversion to and
  428. from Fixed are only appropriate if you are NOT using the floating point unit.
  429. The ones defined below are faster and work with or without the FPU.
  430. */
  431. #define LongToFix(x) ((long)(x)<<16)
  432. #define FixToLong(x) ((x)>>16)
  433. #define DoubleToFix(x) ((long)((x)*65536.+0.5))
  434. #define FixToDouble(x) ((double)(x)*(1./65536.))
  435.  
  436. #if MAC_C
  437.     /*
  438.     STACK
  439.     StackGrow(n) increases the stack allocation by n bytes. You'll also want to use
  440.     Apple's StackSpace(), declared in Memory.h, that returns the number of bytes 
  441.     allocated for the stack.
  442.     */
  443.     #define StackGrow(extraBytes) SetApplLimit(GetApplLimit()-(extraBytes))
  444. #endif
  445.  
  446. /* Assign.c */
  447.  
  448. #define ASSIGN_DIMS 3        /* Feel free to increase or decrease ASSIGN_DIMS. */
  449. typedef struct {
  450.     short type;
  451.     unsigned sizedOnce:1;    /* dim[] is meaningful */
  452.     unsigned sized:1;        /* dim[] is final */
  453.     unsigned malloced:1;    /* allocated by malloc */
  454.     char *name;
  455.     void *ptr;                /* for array, address of element zero */
  456.     long dim[ASSIGN_DIMS];    /* zero indicates a scalar */
  457.     long firstElement;        /* for 1-d array, index of first array element. Usually 0 */
  458.     const char *comment;    /* text string, or NULL */
  459. } Description;
  460. enum{assignReportUnknown=1,assignNoHexInts=2,assignHexFloats=4
  461.     ,assignNoComment=8,assignNoPrintfExit=0x10
  462.     ,assignEchoAssignments=0x20,assignEchoComments=0x40,assignEchoFile=0x80
  463. };
  464. enum {assignMemoryError=-1,assignTypeError=-2
  465.     ,assignVariableError=-3,assignUnknownVariableError=-4
  466.     ,assignSubscriptError=-5,assignSubscriptBoundsError=-6
  467.     ,assignEqualsError=-7,assignConstantError=-8,assignHexError=-9
  468.     ,assignSemicolonError=-10,assignFileError=-11
  469.     ,assignInconsistentDescriptionsError=-12,assignUnequalDataError=-13
  470.     ,assignInconsistentDimensionsError=-14
  471.     ,assignCouldntFindDescription=-15
  472. };
  473. enum{charType=1,unsignedCharType,shortType,unsignedShortType
  474.     ,longType,unsignedLongType
  475.     ,floatType
  476.     #if SHORT_DOUBLE_OK
  477.         ,shortDoubleType
  478.     #endif
  479.     ,doubleType
  480.     ,charPtrType,unsignedCharPtrType,shortPtrType,unsignedShortPtrType
  481.     ,longPtrType,unsignedLongPtrType
  482.     ,floatPtrType
  483.     #if SHORT_DOUBLE_OK
  484.         ,shortDoublePtrType
  485.     #endif
  486.     ,doublePtrType
  487.     ,stringType,unknownType
  488. };
  489. FILE *OpenCalFileRead(char *filename);
  490. FILE *OpenCalFileReadAndCheck(char *filename);
  491. FILE *OpenCalFileWrite(char *filename);
  492. void AppendDescriptions(Description **d,Description *s);
  493. void CopyDescriptions(Description *d,Description *s);
  494. Description *AllocateDescriptions(long n);
  495. void FreeDescriptions(Description *d);
  496. long NumberOfDescriptions(Description *d);
  497. Description NullDescription(void);
  498. int IsNullDescription(Description d);
  499. #define IsNullDescription(d) ((d).type==0)
  500. int AssignmentLineWasBlank(void);
  501. int UnequalDescribedVars(Description d1[],Description d2[],short flags);
  502. int UnequalDescribedVarPair(Description *d1,Description *d2,short flags);
  503. int CopyDescribedVars(Description d1[],Description d2[],short flags);
  504. int CopyDescribedVarPair(Description *d1,Description *d2,short flags);
  505. long InitializeADescribedVar(Description *d,short flags);
  506. long InitializeDescribedVars(Description d[],short flags);
  507. long FindDescribedDim(Description d[],void *ptr,int i,short flags);
  508. long FindDescription(Description d[],void *ptr,short flags);
  509. void FreeADescribedVar(Description *d,short flags);
  510. void FreeDescribedPtrVars(Description d[],short flags);
  511. void FreeDescribedVars(Description d[],short flags);
  512. void KeepDescribedVars(Description d[],short flags);
  513. void KeepADescribedVar(Description *d,short flags);
  514. long PrintAnAssignment(FILE *stream,Description *d,short flags);
  515. long PrintAssignments(FILE *stream,Description d[],short flags);
  516. long PrintAssignmentsToFile(const char *filename,Description d[],short flags);
  517. long ReadAssignmentLine(FILE *stream,Description d[],short flags);
  518. long ReadAssignmentBlock(FILE *stream,Description d[],short flags);
  519. long ReadAssignmentStream(FILE *stream,Description d[],short flags);
  520. long ReadAssignmentFile(const char *filename,Description d[],short flags);
  521. Description Describe(short type,void *ptr,char *name,const char *comment);
  522. Description DescribeArray(short type,void *ptr,char *name,const char *comment,...);
  523. Description DescribeFirstLast(short type,void *ptr,char *name
  524.     ,const char *comment,long firstElement,long lastElement);
  525.  
  526. /* Binomial.c */
  527.  
  528. long    BinomialSample(double p,long n);
  529. int        BinomialSampleQuickly(int n);
  530. double    BinomialLowerBound(double P,long k,long n);
  531. double    BinomialUpperBound(double P,long k,long n);
  532. double    BinomialPdf(double p,long k,long n);
  533. double    Binomial(double p,long k,long n);
  534. double    IncompleteBeta(double x,double a,double b);
  535. double    InverseBinomial(double P,long k,long n);
  536. double    InverseIncompleteBeta(double p,double a,double b);
  537.  
  538. /* BreakLines.c */
  539.  
  540. char *BreakLines(char *string,long lineLength);
  541. void PrintWrappedText(FILE *stream,const char *s);
  542. void PrintWrappedTextToFile(const char *filename,const char *s);
  543. void PrintWrappedComment(FILE *stream,const char *s);
  544. void PrintWrappedCommentToFile(const char *filename,const char *s);
  545.  
  546. #if MAC_C
  547.     /* CardSlot.c */
  548.     
  549.     OSErr    CardSlot(char *cardName);
  550.     
  551.     /* CenterRectInRect.c */
  552.     
  553.     void    CenterRectInRect(Rect *moveableRectPtr,Rect *fixedRectPtr);
  554.     void    OffsetRectTile(Rect *r,int nx,int ny);
  555.     Boolean IsRectInRect(Rect *r,Rect *R);
  556.  
  557. #endif
  558.  
  559. /* ChiSquare.c */
  560.  
  561. double    PChiSquare (double chiSquare,int n);
  562.  
  563. /* Choose.c */
  564.  
  565. #if !MAC_C
  566.     #define Boolean unsigned char
  567. #endif
  568. int Choose(int defaultChoice,const char *query,char *choices[],int n);
  569. char *ChoiceStr(char *choices[],int n);
  570. int MultipleChoice(short defaultChoice,short n,char *choices[]);
  571. Boolean YesOrNo(Boolean defaultAnswer);
  572. extern char *noYes[];
  573. #if !MAC_C
  574.     #undef Boolean
  575. #endif
  576.  
  577. #if MAC_C
  578.     /* ChooseScreen.c */
  579.     
  580.     int ChooseScreen(int screen,const char *question);
  581.  
  582.     /* ConvolveX.c */
  583.     
  584.     void    ConvolveX(double f[],int dim,BitMap *srcBits,BitMap *dstBits,
  585.                 Rect *srcRectPtr,Rect *dstRectPtr);
  586.  
  587.     /* ConvolveY.c */
  588.     
  589.     void ConvolveY(double f[],int dim,BitMap *srcBits,BitMap *dstBits,
  590.                 Rect *srcRectPtr,Rect *dstRectPtr);
  591.     
  592.     /* CopyBitsQuickly.c */
  593.     
  594.     enum{addOverQuickly=40,addOverParallel=40,mulOver};
  595.     int    CopyBitsQuickly(BitMap *srcBits,BitMap *dstBits
  596.         ,Rect *srcRectPtr,Rect *dstRectPtr,long srcMode,RgnHandle maskRgn);
  597.     
  598.     /* CopyQuickDrawGlobals.c */
  599.     
  600.     void CopyQuickDrawGlobals(void);
  601.     #define CopyQuickdrawGlobals CopyQuickDrawGlobals    /*  old spelling */
  602.     
  603.     /* CopyWindows.c */
  604.     
  605.     enum{copyLiterally=0x10000,copyColorize=0x20000};
  606.     enum{srcCopyLiterally=srcCopy+copyLiterally,addOverLiterally=addOver+copyLiterally
  607.         ,addOverParallelLiterally=addOverParallel+copyLiterally
  608.         ,mulOverLiterally=mulOver+copyLiterally};
  609.     int CopyWindows(CWindowPtr srcWindow,CWindowPtr dstWindow
  610.         ,Rect *srcRectPtr,Rect *dstRectPtr,long srcMode,RgnHandle maskRgn);
  611.  
  612.     /* CreateTrialSnds.c */
  613.     
  614.     void CreateTrialSnds(void);
  615. #endif
  616.  
  617. /* DatedString.c */
  618.  
  619. char    *DatedString(unsigned long seconds);
  620.  
  621. #if MAC_C
  622.     /* DrawPrintf.c */
  623.     
  624.     void DrawPrintf(char *s, ...);
  625. #endif
  626.  
  627. /* Exponential.c */
  628.  
  629. double ExponentialPdf(double x);
  630.  
  631. /* ffprintf.c */
  632.  
  633. int ffprintf(FILE *stream[2],char *format,...);
  634.  
  635. #if MAC_C
  636.     /* FlushCacheRange.c */
  637.     
  638.     void FlushCacheRange (void *address, unsigned long count);
  639.     
  640.     /* fp.c */
  641.     
  642.     /* These 3 prototypes appear in Apple's fp.h, but only when it's compiled for */
  643.     /* the PowerPC, not for the 68k. Apple has promised to eventually make the routines */
  644.     /* available on both platforms. In the meantime the VideoToolbox provides the routines */
  645.     /* for 68k machines, so that your programs can use these functions without worrying */
  646.     /* about which platform you might run on. */
  647.     /* Apple's current header files define extended80 in <Types.h>. However, some older */
  648.     /* compilers may have old header files that only define extended80 in <SANE.h>. */
  649.     /* In that case, comment out any offending prototypes below, and paste them */
  650.     /* directly into your source files, after "#include <SANE.h>". The SANE.h header */
  651.     /* file has side effects, so you shouldn't include it here */
  652.     /* or in any file that doesn't really need it. Alternatively, instead of including */
  653.     /* all of SANE.h, you could just copy the definition of extended80. We can't do that */
  654.     /* here because it's an error to repeat a typedef. */
  655.  
  656.     #if !__powerc
  657.         void ldtox80(long double *x,extended80 *x80);
  658.         void x80told(extended80 *x80,long double *x);
  659.         long int fpclassify(double x);
  660.     #endif
  661.  
  662.     /* GDOpenWindow.c */
  663.     
  664.     void AddExplicitPalette(WindowPtr window);
  665.     void RemovePalette(WindowPtr window);
  666.     WindowPtr GDOpenWindow1(GDHandle device);
  667.     void GDDisposeWindow1(WindowPtr window);
  668.     CWindowPtr GDOpenWindow(GDHandle device);
  669.     void GDDisposeWindow(CWindowPtr myWindow);
  670.     void GDGrayColorTable(GDHandle device);
  671.     void SwapWindowExplicitMode(CWindowPtr window,Boolean *explicit);
  672.     BitMap *GetBitMapPtr(CWindowPtr window);
  673.     Boolean IsGWorldPtr(CWindowPtr window);
  674.     Boolean IsGrafPtr(CWindowPtr window);
  675.     
  676.     /* GDPrintf.c */
  677.     
  678.     void GDPrintf(char *s, ...);
  679.     
  680.     /* GDTime.c */
  681.     
  682.     double GDFrameRate(GDHandle device);
  683.     double GDMovieRate(GDHandle device,int quickly);
  684.     double GDMovieSize(GDHandle device,int quickly);
  685.     double GDVBLRate(GDHandle device);
  686.     double TickRate(void);
  687.     typedef OSErr (*SetEntriesFunction)(GDHandle device,short start,short count
  688.         ,ColorSpec *aTable);
  689.     OSErr GDTimeClut(GDHandle device,SetEntriesFunction function,short clutEntries
  690.         ,double *sPtr,double *framesPtr,double *missingFramesPtr,double *frameRatePtr);
  691.     
  692.     /* GDVideo.c */
  693.     
  694.     #define MAX_SCREENS 8
  695.     char  *GDCardName(GDHandle device);
  696.     extern short gdClutSizeTable[33];
  697.     short GDClutSize(GDHandle device);
  698.     long GDColors(GDHandle device);
  699.     OSErr GDControl(int refNum,int csCode,Ptr csParamPtr);
  700.     short GDDacSize(GDHandle device);
  701.     OSErr GDDirectSetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
  702.     OSErr GDGetDisplayMode(GDHandle device,unsigned short *displayModePtr,unsigned long *spIDPtr
  703.         ,unsigned short *pagePtr,Ptr *baseAddrPtr);
  704.     OSErr GDGetDefaultGamma(GDHandle device,GammaTbl **gammaTbl);
  705.     OSErr GDGetDefaultMode(GDHandle device,short *modePtr);
  706.     OSErr GDGetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
  707.     OSErr GDGetGamma(GDHandle device,GammaTbl **myGammaTblHandle);
  708.     OSErr GDGetGray(GDHandle device,Boolean *flagPtr);
  709.     OSErr GDGetInterrupt(GDHandle device,Boolean *flagPtr);
  710.     OSErr GDGetMode(GDHandle device,short *modePtr,short *pagePtr,Ptr *baseAddrPtr);
  711.     OSErr GDGetPageBase(GDHandle device,short page,Ptr *baseAddrPtr);
  712.     OSErr GDGetPageCnt(GDHandle device,short mode,short *pagesPtr);
  713.     OSErr GDGrayPage(GDHandle device,short page);
  714.     Boolean GDHasMode(GDHandle device,short mode,short *pixelSizePtr,short *pagesPtr);
  715.     short GDModePixelSize(GDHandle device,short mode);
  716.     unsigned char *GDName(GDHandle device);
  717.     char *GDNameStr(GDHandle device);
  718.     ColorSpec *GDNewLinearColorTable(GDHandle device);
  719.     short GDPixelSize(GDHandle device);
  720.     OSErr GDPrintGammaTable(FILE *o,GDHandle device);
  721.     OSErr GDReset(GDHandle device,short *modePtr,short *pagePtr,Ptr *baseAddrPtr);
  722.     OSErr GDRestoreDeviceClut(GDHandle device);
  723.     OSErr GDRestoreGamma(GDHandle device);
  724.     OSErr GDSaveGamma(GDHandle device);
  725.     OSErr GDSetDefaultMode(GDHandle device,short mode);
  726.     OSErr GDSetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
  727.     OSErr GDSetEntriesByType(GDHandle device,short start,short count,ColorSpec *table);
  728.     OSErr GDSetEntriesByTypeHighPriority(GDHandle device,short start,short count
  729.         ,ColorSpec *table);
  730.     OSErr GDSetGamma(GDHandle device,GammaTbl *myGammaTblPtr);
  731.     OSErr GDSetGray(GDHandle device,Boolean flag);
  732.     OSErr GDSetInterrupt(GDHandle device,Boolean flag);
  733.     OSErr GDSetMode(GDHandle device,short mode,short page,Ptr *baseAddrPtr);
  734.     OSErr GDSetPageDrawn(GDHandle device,short page);
  735.     OSErr GDSetPageShown(GDHandle device,short page);
  736.     OSErr GDStatus(int refNum,int csCode,Ptr csParamPtr);
  737.     short GDType(GDHandle device);
  738.     OSErr GDUncorrectedGamma(GDHandle device);
  739.     int  GDVersion(GDHandle device);
  740.     int  PatchMacIIciVideoDriver(void);
  741.     
  742.     /* GetClicks.c */
  743.     
  744.     short    GetClicks(void);
  745. #endif
  746.  
  747. /* GetTimeDateString.c */
  748.  
  749. char *GetTimeDateString(time_t t);
  750.  
  751. #if MAC_C
  752.     /* GetVersionString.c */
  753.  
  754.     char *GetVersionString(void);
  755.  
  756.     /* GetScreenDevice.c */
  757.     
  758.     GDHandle    GetScreenDevice(int n);
  759.     int            GetScreenIndex(GDHandle device);
  760.     GDHandle    SlotToScreenDevice(int n);
  761.     GDHandle    GetDeviceByRefNum(int n);
  762.     short int    GetDeviceSlot(GDHandle device);
  763.     GDHandle    GetWindowDevice(WindowPtr theWindow);
  764.     GDHandle    GetRectDevice(Rect *r);
  765.     void        LocalToGlobalRect(Rect *r);
  766.     void        GlobalToLocalRect(Rect *r);
  767.  
  768.     /* GetVoltage.c */
  769.     
  770.     double    VoltsDuringFrame(double frames);
  771.     double    GetVoltage(short channel,double *gainPtr,double *frequencyPtr,long n
  772.                 ,double *sdPtr);
  773.     short    GetVoltages(short channel,double *gainPtr,double *frequencyPtr,long *nPtr
  774.                 ,unsigned short readings[],double *voltDeltaPtr,double *voltZeroPtr);
  775.     short    InitiateVoltageSampling(short channel,double *gainPtr,double *frequencyPtr
  776.                 ,double *voltDeltaPtr,double *voltZeroPtr);
  777.     short    RetrieveVoltages(long *nPtr,unsigned short readings[]);
  778.     int        ForeRunnerSlot(void);
  779.     enum{voltageBufferOverflow=1<<0,voltageOverflow=1<<1,voltageUnderflow=1<<2};
  780. #endif
  781.  
  782. /* HexToBinary.c */
  783.  
  784. int HexToBinary(char *string,void *ptr);
  785. char *BinaryToHex(size_t n,void *ptr,char *string);
  786.  
  787. #if MAC_C
  788.     /* HideMenuBar.c */
  789.     
  790.     void    HideMenuBar(void);
  791.     void    ShowMenuBar(void);
  792.     void SquareCorners(GDHandle device);
  793.     void RestoreCorners(GDHandle device);
  794.     void UnclipScreen(GDHandle device);
  795.     void RestoreScreenClipping(GDHandle device);
  796.     
  797.     /* Identify.c */
  798.     
  799.     char *IdentifyApplication(void);
  800.     char *IdentifyCompiler(void);
  801.     char *IdentifyMachine(void);
  802.     char *IdentifyModel(void);
  803.     char *IdentifyOwner(void);
  804.     char *IdentifyVideo(GDHandle device);
  805.     
  806.     /* ImageStatistics */
  807.  
  808.     double ImageEnergy(GWorldPtr aWorld,Rect *aRect,double background);
  809.     void ImageStatistics(GWorldPtr world,Rect *rect
  810.         ,long *minPtr,long *maxPtr,double *meanPtr,double *meanSquarePtr);
  811.  
  812.     /* IsCmdPeriod.c */
  813.     
  814.     Boolean IsCmdPeriod(EventRecord *event);
  815. #endif
  816.  
  817. /* IsNan.c */
  818.  
  819. int IsNan(double x);
  820. int IsInf(double x);
  821. #ifndef IsFinite    /* neither NAN nor ±INF */
  822.     #define IsFinite(x) \
  823.     (sizeof(x)>8?    \
  824.     ((*(short *)&(x) & 0x7FFF)!=0x7FFF)        /* 10 or 12 byte double */\
  825.     :((*(short *)&(x) & 0x7FF0)!=0x7FF0))    /* 8 byte double */
  826. #endif
  827.  
  828. #if MAC_C
  829.     /* kbhit.c */
  830.     
  831.     int    kbhit(void);
  832.     int    getcharUnbuffered(void);
  833. #endif
  834.  
  835. /* Log2L.c */
  836.  
  837. long Log2L(unsigned long j);
  838.  
  839. #if MAC_C
  840.     
  841.     /* MaximizeConsoleHeight.c */
  842.     
  843.     void MaximizeConsoleHeight(void);
  844. #endif
  845.  
  846. /* Mean.c */
  847.  
  848. double Mean(double x[],long n,double *sdPtr);
  849. double MeanF(float x[],long n,double *sdPtr);
  850. double MeanB(char x[],long n,double *sdPtr);
  851. double MeanUB(unsigned char x[],long n,double *sdPtr);
  852. double MeanW(short x[],long n,double *sdPtr);
  853. double MeanUW(unsigned short x[],long n,double *sdPtr);
  854. double MeanL(long x[],long n,double *sdPtr);
  855. double MeanUL(unsigned long x[],long n,double *sdPtr);
  856.  
  857. /* Nan.c */
  858. extern const short __NAN[];
  859. #define Nan (*(double *)__NAN)
  860.  
  861. /* NoiseFill.c */
  862.  
  863. int NoiseFill(CWindowPtr window,Rect *r,double dx,double dy,Boolean randomPhase);
  864. int NoiseFillBits(PixMap *bits,Rect *r,double dx,double dy,Boolean randomPhase);
  865. int MakeNoise1(double dx,double dy,Boolean randomPhase,PixMap *bits);    /* Obsolete */
  866.  
  867. /* Normal.c */
  868.  
  869. double NormalPdf(double x);
  870. double Normal(double x);
  871. double InverseNormal(double p);
  872. double NormalSample(void);
  873. double Normal2DPdf(double r);
  874. double Normal2D(double r);
  875. double InverseNormal2D(double p);
  876. double Normal2DSample(void);
  877. double InverseNormal2DPdf(double p);
  878. void BoundedNormalIntegers(short *distribution,long n,double mean,double sd
  879.     ,short min,short max);
  880.  
  881. /* nrand.c */
  882.  
  883. unsigned long nrand(unsigned long n);
  884.  
  885. /* OpenDataFiles.c */
  886.  
  887. unsigned long OpenDataFiles(FILE **inPtr,FILE **outPtr
  888.                     ,char *inName,char *outName);
  889.  
  890. /* OpenPreferencesFolder.c */
  891.  
  892. #if !MAC_C
  893.     #define OSErr short
  894. #endif
  895. OSErr OpenPreferencesFolder(void);
  896. OSErr ClosePreferencesFolder(void);
  897. OSErr OpenPreferencesWD(short *wdRefNumPtr);
  898. #if !MAC_C
  899.     #undef OSErr
  900. #endif
  901.  
  902. #if MAC_C
  903.     /*    PixMapToPICT.c */
  904.  
  905.     void PixMapToPICT(char *filename,PixMap **pm,Rect *rectPtr
  906.         ,int pixelSize,ColorTable **cTable);
  907.  
  908.     /*    PixMapToPostScript.c */
  909.     
  910.     void WindowToEPS(CWindowPtr window,char *filename,Rect *rectPtr
  911.         ,Rect *pageRectPtr,double cellsPerInch,int grayLevels,float reflectance[256]);
  912.     void PixMapToEPS(char *filename,PixMap **pm,Rect *rectPtr
  913.         ,Rect *pageRectPtr,double cellsPerInch,int grayLevels);
  914.     void PixMapToPostScript(char *filename,PixMap **pm,Rect *rectPtr
  915.         ,Rect *pageRectPtr,double cellsPerInch,int grayLevels);
  916.     void AppendToFile(char *filename,char *string);
  917.     
  918.     /* PlotXY.c */
  919.     
  920.     typedef struct{
  921.         Boolean continuing;    /* zero to start a new curve */
  922.         long color;            /* e.g. blackColor, blueColor */
  923.         short lineWidth;    /* in pixels, zero for none */
  924.         short symbolWidth;    /* in pixels, zero for none */
  925.         short dashOffset;    /* in pixels */
  926.         short dash[5];        /* in pixels. The array is terminated by a zero element */
  927.         short h,v;            /* reserved for internal use */
  928.         Fixed pathLengthF;    /* reserved for internal use */
  929.     } PlotXYStyle;
  930.     void PlotXY(WindowPtr window,double x,double y,PlotXYStyle *style);
  931. #endif
  932.  
  933. /* PrintfExit.c */
  934.  
  935. int PrintfExit(const char *format,...);
  936.  
  937. #if MAC_C
  938.  
  939.     /* PrintfGWorld.c */
  940.  
  941.     void PrintfGWorld(GWorldPtr our);
  942.     void PrintStringAsBitmap(unsigned char *s);
  943.  
  944.     /* QD32Exists.c */
  945.     
  946.     Boolean         QD8Exists(void);
  947.     Boolean            QD32Exists(void);
  948.     Boolean            NewPaletteManager(void);
  949. #endif
  950.  
  951. /* randU.c */
  952.  
  953. unsigned short    randU(void);
  954. unsigned long    randUL(void);
  955. void            srandU(unsigned n);
  956. void            RandFill(void *address,long bytes);
  957.  
  958. /* ReadMATLABFile.c */
  959.  
  960. int LoadNamedMatIntoDoubles(FILE *f,const char *name,long *rows,long *cols
  961.     ,double **real,double **imag);
  962. int LoadNamedMatIntoShorts(FILE *f,const char *name,long *rows,long *cols
  963.     ,short **real,short **imag);
  964. int LoadNextMatIntoDoubles(FILE *f,char *name,long *rows,long *cols
  965.     ,double **real,double **imag);
  966. int LoadNextMatIntoShorts(FILE *f,char *name,long *rows,long *cols
  967.     ,short **real,short **imag);
  968. int SaveMatDoubles(FILE *f,char *name,long rows,long cols,double *real,double *imag);
  969. int SaveMatShorts(FILE *f,char *name,long rows,long cols,short *real,short *imag);
  970.  
  971. #if MAC_C
  972.     /* RectToAddress.c */
  973.     
  974.     unsigned char *RectToAddress(PixMap *pixMapPtr,Rect *rectPtr,short *rowBytesPtr, 
  975.         short *pixelSizePtr,short *bitsOffsetPtr);
  976.     Ptr GetPixBaseAddr32(PixMap **pm);
  977. #endif
  978.     
  979. /*    Require.c    */
  980.  
  981. void Require(long quickDrawVersion);
  982. struct PrecompileSizeofInt{
  983.     int i;
  984. };
  985. struct PrecompileSizeofDouble{
  986.     double d;
  987. };
  988.  
  989. #if MAC_C
  990.     /* RestoreCluts.c */
  991.     
  992.     void RestoreCluts(void);
  993.     
  994.     /*    SetEntriesQuickly.c */
  995.     
  996.     OSErr SetEntriesQuickly(GDHandle device,short start,short count,ColorSpec *table);
  997.     short macltset(GDHandle device,register short start
  998.         ,unsigned short *red,unsigned short *green,unsigned short *blue,short count1);
  999.     short GetCardType(GDHandle device);
  1000.     char *GetCardBase(GDHandle device);
  1001.     OSErr WaitForNextBlanking(GDHandle device);
  1002.     
  1003.     /* SetFileInfo.c */
  1004.     
  1005.     void    SetFileInfo(char *fileName,OSType fileType,OSType fileCreator);
  1006.     
  1007.     /* SetMouse.c */
  1008.     
  1009.     void    SetMouse(Point where);
  1010.     
  1011.     /* SetOnePixel.c */
  1012.     
  1013.     void SetPixmapPixel(PixMap *pmHandle,int x,int y,unsigned long value);
  1014.     unsigned long GetPixmapPixel(PixMap *pmHandle,int x,int y);
  1015.     unsigned char *GetPixmapPixelAddress(PixMap *pmHandle,int x,int y);
  1016.     void SetDevicePixel(GDHandle device,int x,int y,unsigned long value);
  1017.     unsigned long GetDevicePixel(GDHandle device,int x,int y);
  1018.     void SetOnePixel(int x,int y,unsigned long value);
  1019.     unsigned long GetOnePixel(int x,int y);
  1020.     #define SetIPixel SetDevicePixel    /*  So that old programs won't break. */
  1021.     #define GetIPixel GetDevicePixel    /*  So that old programs won't break. */
  1022.     
  1023.     /* SetPixelsQuickly.c */
  1024.     
  1025.     int SetPixelsQuickly(int x,int y,unsigned long value[],short n);
  1026.     int GetPixelsQuickly(int x,int y,unsigned long value[],short n);
  1027.     int SetWindowPixelsQuickly(WindowPtr window,int x,int y,unsigned long value[],short n);
  1028.     int GetWindowPixelsQuickly(WindowPtr window,int x,int y,unsigned long value[],short n);
  1029.     int SetDevicePixelsQuickly(GDHandle device,int x,int y,unsigned long value[],short n);
  1030.     int GetDevicePixelsQuickly(GDHandle device,int x,int y,unsigned long value[],short n);
  1031.     int SetPixmapPixelsQuickly(PixMapPtr pmPtr,int x,int y,unsigned long value[],short n);
  1032.     int GetPixmapPixelsQuickly(PixMapPtr pmPtr,int x,int y,unsigned long value[],short n);
  1033.     
  1034.     /* SetPriority.c */
  1035.     
  1036.     void SwapPriority(char *priority);
  1037.     void SetPriority(int i);
  1038.     int GetPriority(void);
  1039. #endif
  1040.  
  1041. /* Shuffle.c */
  1042.  
  1043. void Shuffle(void *array,long elements,size_t elementSize);
  1044.  
  1045. #if MAC_C
  1046.     /* SndPlay1.c */
  1047.     
  1048.     OSErr SndPlay1(Handle snd);
  1049.     void SndStop1(void);
  1050.     short SndDone1(void);
  1051.  
  1052.     /* StringToDateAndSecs.c */
  1053.     
  1054.     double StringToDateAndSecs(char *string,DateTimeRec *date);
  1055.  
  1056.     /* StringBounds.c */
  1057.     
  1058.     void CharBounds(char a,Rect *bounds,long *count);
  1059.     void StringBounds(const unsigned char *s,Rect *bounds,long *count);
  1060.     void StrBounds(char *s,Rect *bounds,long *count);
  1061.  
  1062.     /* Timer.c */
  1063.     
  1064.     struct Timer{
  1065.         TMTask time;
  1066.         long ourA5;
  1067.         long interval,elapsed,elapsedIntervals;
  1068.         long timeToStartTimer;            /*  minimum time in µs */
  1069.         long stopDelay;                    /*  µs from call to stop, re from call to start */
  1070.         long timeManagerVersion;
  1071.         struct Timer *next,*previous;    /*  doubly linked list of Timers */
  1072.     };
  1073.     typedef struct Timer Timer;
  1074.     
  1075.     Timer *NewTimer(void);
  1076.     void DisposeTimer(Timer *t);
  1077.     void StartTimer(Timer *t);
  1078.     long StopTimer(Timer *t);                    /*  µs */
  1079.     double StopTimerSecs(Timer *t);                /*  s */
  1080.     long PeekTimer(Timer *t);                    /*  µs */
  1081.     double PeekTimerSecs(Timer *t);                /*  s */
  1082.     
  1083.     /* TitleBarHeight.c */
  1084.     
  1085.     int TitleBarHeight(WindowPtr window);
  1086.     
  1087.     /* TrapAvailable.c */
  1088.     
  1089.     Boolean    TrapAvailable(short theTrap);
  1090. #endif
  1091.  
  1092. /* Uniform.c */
  1093.  
  1094. double UniformSample(void);
  1095.  
  1096. #if MAC_C
  1097.     /* VBLInstall.c */
  1098.     
  1099.     struct VBLTaskAndA5 {
  1100.         volatile VBLTask vbl;
  1101.         long ourA5;
  1102.         #if USESROUTINEDESCRIPTORS || GENERATINGCFM
  1103.             UniversalProcPtr subroutine;
  1104.         #else
  1105.             void (*subroutine)(struct VBLTaskAndA5 *vblData);
  1106.         #endif
  1107.         GDHandle device;
  1108.         long slot;
  1109.         volatile long newFrame;        /* Boolean */
  1110.         volatile long frame;        /* count up from zero */
  1111.         volatile long framesLeft;    /* count down to zero */
  1112.         long framesDesired;
  1113.         Timer *frameTimer;            /* time ms since last VBL interrupt, see Timer.c */
  1114.         void *ptr;                    /* use this for whatever you want */
  1115.     };
  1116.     typedef struct VBLTaskAndA5 VBLTaskAndA5;    
  1117.     OSErr VBLInstall(VBLTaskAndA5 *vblData,GDHandle device,long frames);
  1118.     OSErr VBLRemove(VBLTaskAndA5 *vblData);
  1119.     void SimpleVBLSubroutine(VBLTaskAndA5 *vblData);
  1120.     
  1121.     /* VideoTFB.c */
  1122.     
  1123.     Boolean TFBInSlot(int slot);
  1124.     void    SetUpTFB(int slot);
  1125.     void    RampClutTFB(int slot);
  1126.     void    GrayClutTFB(int slot);
  1127.     void    LoadClutTFB(int slot,unsigned char rgb[256][3]);
  1128.     void    NewBlankingTFB(int slot);
  1129.     void    NewFieldTFB(int slot);
  1130.     int        BlankingTFB(int slot);
  1131.     void    SetDepthTFB(int slot,short int bits);
  1132.     void    SynchSetDepthTFB(int masterSlot,int slot,short int bits);
  1133.     void    SynchToMainDeviceTFB(GDHandle device);
  1134.     void    HaltTFB(int slot);
  1135.     void    RestartTFB(int slot,short int bits);
  1136.     void    HaltDeviceTFB(GDHandle device);
  1137.     void    RestartDeviceTFB(GDHandle device);
  1138.     void    ScrollTFB(int slot,short int bits,long x,long y);
  1139.     void    PanTFB(int slot,long int x);
  1140. #endif
  1141.  
  1142. /* VLambda.c */
  1143.  
  1144. double VLambda(double nm);
  1145. double VLambdaPrime(double nm);
  1146.  
  1147. #if MAC_C
  1148.     /* Zoom.c */
  1149.     
  1150.     void Zoom(WindowPtr theWindow,int zoomDir,EventRecord *event);
  1151. #endif
  1152.  
  1153. #endif /* _VIDEOTOOLBOX_ */
  1154.